import request from 'umi-request';


// 获取编程题
export const getList = async (data: any) => {
    return request<any>('/questions/type', {
        method: 'GET',
        params: { type: data }
    });
};

// 添加题目
export const addQuestions = async (data: any) => {
    return request<any>('/question/add', {
        method: 'post',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 删除题目
export const deleteQuestions = async (data: any) => {
    return request<any>('/question/delete', {
        method: 'GET',
        params: { questionId: data }
    });
};

// 编辑题目
export const editQuestions = async (data: any) => {
    return request<any>('/question/update', {
        method: 'post',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 提交输入用例case
export const addRunCase = async (data: any) => {
    return request<any>('/code/case/save', {
        method: 'post',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 运行case
export const runCase = async (data: any) => {
    return request<any>('/code/run', {
        method: 'post',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 查看结果
export const checkCase = async (data: any) => {
    return request<any>('/code/checkStatus', {
        method: 'GET',
        params: { codeId: data }
    });
};


